﻿using System;
using BLL;
using Model;

public partial class PCBA_PCBAJointingCheck_PCBAJointingCheckAdd : System.Web.UI.Page
{
    PCBAJointingCheck pjc;

    public PCBA_PCBAJointingCheck_PCBAJointingCheckAdd()
    {
        pjc = new PCBAJointingCheck();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindJointingFailure();
        }
    }

    protected void BindJointingFailure()
    {
        JointingFailure jf = new JointingFailure();
        this.DropDownList1.DataSource = jf.JointingFailure_GetbySMT();
        this.DropDownList1.DataValueField = "FailureName";
        this.DropDownList1.DataTextField = "FailureName";
        this.DropDownList1.DataBind();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        string productSN = this.TextBox2.Text.Trim();
        this.GridView1.DataSource = pjc.GetPCBAJointingChecksbySN(productSN);
        this.GridView1.DataBind();
    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        Page.Validate("VGroup1");
        if (Page.IsValid)
        {
            string pCBASN = this.TextBox1.Text.Trim();
            PCBAJointingCheckInfo pjci = new PCBAJointingCheckInfo(pCBASN, DateTime.Now, this.TextBox3.Text.Trim(), this.DropDownList1.SelectedValue);
            try
            {
                pjc.Insert(pjci);
                this.TextBox1.Text = "";
                this.TextBox1.Focus();
                string str = pCBASN + " 录入成功！";
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
            }
            catch
            {
                string str = "出现错误，请联系相关人员！";
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
            }
        }
    }
}
